package OOAE_UWE.Assessment;

import java.text.SimpleDateFormat;
import java.util.Date;

// realize rental -> method of attain room information
public class RentalAgreementImpl implements RentalAgreement {
    private final Room room;
    private final Student student;
    private final Date startDate;
    private final Date endDate;

    public RentalAgreementImpl(Room room, Student student, Date startDate, Date endDate) {
        this.room = room;
        this.student = student;
        this.startDate = startDate;
        this.endDate = endDate;
        room.setRented(true); // sign room rented
    }

    @Override
    public void executeTerms() {
        SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
        String formattedStartDate = sdf.format(startDate);
        String formattedEndDate = sdf.format(endDate);
        StringBuilder message = new StringBuilder();
        message.append("Student ID: ").append(student.getId()).append("\n");
        message.append("Name: ").append(student.getName()).append("\n");
        message.append("Rent Room: ").append(room.getRoomNumber()).append(" successfully.\n");
        message.append("Time: from ").append(formattedStartDate).append(" to ").append(formattedEndDate);
        System.out.println(message.toString());
    }
}


